package org.capi.capi20;

/**
 * The class {@code CapiException} and its subclasses indicate error conditions
 * which a CAPI application programmer might want to catch and handle.
 *
 * <p>A {@code CapiException} encapsulates a CAPI error code.
 */
public class CapiException extends Exception {

    /** The CAPI error code of this {@code CapiException}. */
    private short _errorCode;

    /**
     * Constructs a new {@code CapiException} with the specified
     * CAPI error code.
     *
     * @param errorCode The CAPI error code.
     * @see Exception#Exception()
     */
    public CapiException(short errorCode) {
        _errorCode = errorCode;
    }

    /**
     * Constructs a new {@code CapiException} with the specified
     * CAPI error code and detail message.
     *
     * @param errorCode The CAPI error code.
     * @param message The detail message.
     * @see Exception#Exception(String)
     */
    public CapiException(short errorCode, String message) {
        super(message);

        _errorCode = errorCode;
    }

    /**
     * Constructs a new {@code CapiException} with the specified
     * CAPI error code, detail message, and cause.
     *
     * @param errorCode The CAPI error code.
     * @param message The detail message.
     * @param cause The cause.
     * @see Exception#Exception(String, Throwable)
     */
    public CapiException(short errorCode, String message, Throwable cause) {
        super(message, cause);

        _errorCode = errorCode;
    }

    /**
     * Returns the CAPI error code of this {@code CapiException}.
     *
     * @return The CAPI error code.
     */
    public short getErrorCode() {
        return _errorCode;
    }

}
